#!/bin/bash

# create docker image
docker build -t wx-rdc/fwknop:v1 .

export FWK_CONF="fwk-conf"

# Initialize the $FWK_CONF container that will hold the configuration files and certificates
docker volume create --name $FWK_CONF
docker run -v $FWK_CONF:/etc/fwknop --rm wx-rdc/fwknop:v1 fwk_genconfig
# set deny rules
docker run -v $FWK_CONF:/etc/fwknop --rm wx-rdc/fwknop:v1 fwk_setrules

# Start Fwknop server process
docker run -v $FWK_CONF:/etc/fwknop -d \
    -p 62201:62201/udp \
    --network container:smocker \
    --privileged \
    --name fwknopd \
    wx-rdc/fwknop:v1
